//
//  YTOrderFlowViewController.m
//  YiTuDriverClient
//
//  Created by 石少庸 on 2017/8/3.
//  Copyright © 2017年 Yitu. All rights reserved.
//

#import "YTOrderFlowViewController.h"
#import "YTOrderFlowViewCell.h"
#import "YTOrderFlowModel.h"
#import "YTOrderServices.h"

@interface YTOrderFlowViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic) NSMutableArray<YTOrderFlowModel *> *dataArray;
@end

@implementation YTOrderFlowViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _dataArray = [NSMutableArray array];
    [[YTOrderServices orderFlowWithOrderID:self.order_id] subscribeNext:^(NSDictionary *response) {
        NSArray<YTOrderFlowModel *> *array = [NSArray yy_modelArrayWithClass:[YTOrderFlowModel class] json:response[@"responseData"]];
        [_dataArray addObjectsFromArray:array];
        [_tableView reloadData];
    }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YTOrderFlowViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YTOrderFlowViewCell" forIndexPath:indexPath];
    [cell configModel:_dataArray[indexPath.row]
            indexPath:indexPath
           isLastLine:((_dataArray.count - 1) == indexPath.row)];
    return cell;
}

@end
